<?php
 
// no direct access
defined('_JEXEC') or die('Restricted access'); ?>

<form action="<?php echo JRoute::_('?option=com_syncr'); ?>" method="post" name="adminForm">
	<table id="adminfilter">
		<tr>
			<td width="100%" nowrap="nowrap">
				<label for="search"><?php echo JText::_('SEARCH'); ?>
					<input type="text" name="search" id="search" class="text_area" value="<?php echo $this->lists['search']; ?>" />
					<button onclick="this.form.submit();"><?php echo JText::_('SEARCH'); ?></button>
					
				</label>
				<button onclick="document.getElementById('search').value=''; this.form.getElementById('filter_state').value=''; this.form.submit;"><?php echo JText::_('RESET_FILTERS'); ?></button>
			</td>
			<td nowrap="nowrap">
				<?php echo $this->lists['state']; ?>
			</td>
		</tr>
	</table>
	
	<table class="adminlist">
		<thead>
			<tr>
				<th width="1%">
					<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->sites); ?>);" />
				</th>
				<th width="1"></th>
				<th>
					<?php echo JHTML::_('grid.sort', 'NAME', 'name', $this->lists['orderDirection'], $this->lists['order']); ?>
				</th>
				<th width="5%">
					<?php echo JHTML::_('grid.sort', 'COLOR', 'color', $this->lists['orderDirection'], $this->lists['order']); ?>
				</th>
				<th width="5%">
					<?php echo JHTML::_('grid.sort', 'IMAGE', 'image', $this->lists['orderDirection'], $this->lists['order']); ?>
				</th>
				<th width="5%">
					<?php echo JHTML::_('grid.sort', 'PUBLISHED', 'published', $this->lists['orderDirection'], $this->lists['order']); ?>
				</th>
			</tr>
		</thead>
		<tbody>
			<?php
			jimport('joomla.filter.output');
			$k = 0;
			
			for ($i = 0, $n = count($this->sites); $i < $n; $i++)
			{
				$site =& $this->sites[$i];
								
				$checked = JHTML::_('grid.checkedout',   $site, $i );
				$link = JRoute::_('?option=com_syncr&controller=sites&task=edit&cid[]='.$site->id);
				$published = JHTML::_( 'grid.published', $site, $i );
				?>
				<tr class="<?php echo 'row'.$k; ?>">
					<td align="center">
						<?php echo $checked; ?>
					</td>
					<td>
						<img src="<?php echo $site->logo; ?>" width="16px" height="16px" /> 
					</td>
					<td>
						<?php
						if (  JTable::isCheckedOut($this->user->get ('id'), $site->checked_out ) ) {
							echo $this->escape($site->name).' ('.$this->escape($site->url).')';
						} else {
						?>
						
					
						<a href="<?php echo $link; ?>">
							<?php echo $site->name.' ('.$this->escape($site->url).')'; ?>
						</a>
						
						<?php } ?>
					</td>
					<td style="background-color: <?php echo $site->color; ?>;"></td>
					<td align="center">
						<?php echo $site->image; ?>
					</td>
					<td align="center">
						<?php echo $published; ?>
					</td>
				</tr>
				<?php
				$k = 1 - $k;
			}
			?>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="6">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
	</table>
	
	<?php echo JHTML::_('form.token'); ?>
	
	<input type="hidden" name="controller" value="sites" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['orderDirection']; ?>" />
</form>